<template>
  &emsp;
  <div style="font-size: 22px">
    断奶日期：<el-date-picker style="width: 100px" v-model="form.start">
    </el-date-picker
    ><el-date-picker style="width: 100px" v-model="form.end"> </el-date-picker
    >&emsp;&emsp; 羔羊耳号：<el-select
      style="width: 100px"
      placeholder="请选择"
      v-model="form.sleepInforId"
    >
      <el-option
        v-for="item in SelectEar"
        :label="item.earNumber"
        :value="item.sleepInforId"
      />
    </el-select>
    &nbsp;&nbsp; 断奶日龄：<el-input
      style="width: 100px"
      v-model="form.startday"
    />--<el-input style="width: 100px" v-model="form.endday" />
    &nbsp;&nbsp;<br /><br />
    断奶重（公斤）：<el-input
      style="width: 100px"
      v-model="form.weightstart"
    />--<el-input style="width: 100px" v-model="form.weightend" /> &nbsp;&nbsp;
    哺乳种母耳号：<el-select style="width: 100px" v-model="form.sleepMonth">
      <el-option
        v-for="item in SelectEar.filter((x:any)=>x.gender==2)"
        :label="item.earNumber"
        :value="item.sleepInforId"
      />
    </el-select>
    &emsp;&emsp;
    <el-button type="danger" size="large" @click="gettableData()"
      >查询</el-button
    >
  </div>
  <br />
  <hr style="font-size: 20px" />
  <br />

  <el-table height="400" border style="width: 100%" :data="tableData">
    <el-table-column type="selection" />
    <el-table-column prop="lambWeaningId" label="序号" />
    <el-table-column prop="earNumber" label="羊只耳号"> </el-table-column>
    <el-table-column prop="ageDay" label="断奶日龄" />
    <el-table-column prop="weaningWeight" label="断奶重(公斤)">
    </el-table-column>
    <el-table-column prop="moEarNumber" label="哺乳种母耳号"> </el-table-column>
    <el-table-column prop="batchNumber" label="胎次"> </el-table-column>
    <el-table-column prop="cottageName" label="断奶栋舍"> </el-table-column>
    <el-table-column prop="fieIdName" label="断奶栏位"> </el-table-column>
    <el-table-column prop="cottagesAfter" label="转入栋舍" />
    <el-table-column prop="fieldAfter" label="转入栏位"> </el-table-column>
    <el-table-column prop="weaningDate" label="断奶日期"> </el-table-column>
    <el-table-column prop="createId" label="创建人" />
    <el-table-column prop="createTime" label="创建时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.createTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="name" fixed="right" width="120" label="操作">
      <template #default="scope"> </template>
    </el-table-column>
  </el-table>
</template>

<script setup lang="ts">
import {
  Check,
  Delete,
  Edit,
  Message,
  Back,
  Plus,
  Setting,
  SuccessFilled,
  Minus,
  Close
} from '@element-plus/icons-vue';
import { reactive, ref, onMounted, computed } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useCounterStore } from '@/stores/counter';

const counterStore = useCounterStore();
const route = useRoute();
const router = useRouter();

onMounted(() => {
  geteweData();
  gettableData();
});

//获取耳号
const SelectEar = ref<any>([]);
const geteweData = () => {
  axios.get('http://localhost:5039/api/SleepBegin/SelectEar').then((res) => {
    SelectEar.value = res.data.item;
  });
};

const form = reactive({
  start: '',
  end: '',
  sleepInforId: '',
  startday: '',
  endday: '',
  weightstart: '',
  weightend: '',
  sleepMonth: ''
});

const tableData: any = ref([]);
const now = new Date();
const gettableData = () => {
  axios
    .post(
      'http://localhost:5039/api/ProductionManagement/Handle/LambWeaningSelect',
      {
        start: form.start || '',
        end: form.end || '',
        sleepInforId: form.sleepInforId || 0,
        startday: form.startday || 0,
        endday: form.endday || 0,
        weightstart: form.weightstart || 0,
        weightend: form.weightend || 0,
        sleepMonth: form.sleepMonth || 0
      }
    )
    .then((res) => {
      console.log(res);
      tableData.value = res.data.data;
    });
};
</script>

<style scoped></style>
